package com.fx.attendance.repository;

import com.fx.attendance.domain.FaceInformation;
import com.fx.domain.system.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * @author Fanxin
 * @date 2018-11-22
 */
public interface FaceInfomationRepository extends JpaRepository<FaceInformation, Long>, JpaSpecificationExecutor<FaceInformation> {

    /**
     * 根据用户查询
     * @param userId 用户Id
     * @return /
     */
    @Query(value = "SELECT fi FROM FaceInformation fi WHERE fi.user.id = ?1")
    FaceInformation findByUserId(String userId);

    /**
     * 查询用户
     * @param userId 用户Id
     * @return /
     */
    @Query(value = "SELECT u FROM User u WHERE u.id = ?1")
    User getUserById(String userId);

}
